<template>
    <div class="meeting-apply">
        <apply-header process-name="新建会议" @cancel-click="cancelClick" @submit-click="submit"/>
        <div class="apply-content">
            <el-form ref="formRef" :model="meeting" :rules="rules" label-position="left" label-width="130px" label-suffix="：">
                <form-title title="会议申请"/>
            </el-form>
        </div>
    </div>
</template>

<script>
import {getCurrentInstance, reactive, ref, toRefs} from "vue";
import {ElLoading, ElMessage} from "element-plus";
import ApplyHeader from "../../com/apply/ApplyHeader.vue";
import FormTitle from "../../com/apply/FormTitle.vue";

export default {
    name: "AddMeetingForm",
    components: {FormTitle, ApplyHeader},
    setup(prop,{emit}){
        const formRef = ref(null);
        const globalProperties = getCurrentInstance()?.appContext.config.globalProperties;
        const form = reactive({
            meeting:{

            },
            rules:{
                name: [
                    {required: true,message:'请输入会议主题',trigger:'blur'}
                ],
            },
            submit(){
                formRef.value.validate((valid)=>{
                    if(valid){
                        let loading = ElLoading.service({
                            lock: true,
                            text: '',
                        });
                        // createMeeting(meeting).then(vo=>{
                        //     loading.close();
                        //     globalProperties.$response.handle({
                        //         data:vo,
                        //         success:'会议申请成功...',
                        //         successFn:()=>{
                        //             form.resetForm();
                        //             let returnUrl = this.$route.query.returnUrl;
                        //             // if(returnUrl){
                        //             //     globalProperties.$router.push(returnUrl);
                        //             // }
                        //         },
                        //         failFn:()=>{
                        //             ElMessage.error('申请失败!');
                        //         }
                        //     })
                        // })
                    }else{
                        ElMessage.error('请先完善表单!');
                    }
                })
            },
            resetForm(){
                formRef.value.clearValidate();
                formRef.value.resetFields();
            }
        })
        return {
            ...toRefs(form),
            formRef
        }
    },
    data(){
        return {
        }
    },
    methods:{
        cancelClick() {
            this.$operate.confirm({
                title: '取消申请',
                hint: '你确认要取消申请吗？',
                executeFn: ()=>{
                    let returnUrl = this.$route.query.returnUrl;
                    if(returnUrl){
                        this.$router.push(returnUrl);
                        // console.log('returnUrl',returnUrl)
                    }else{
                        this.$router.push('/home');
                    }
                }
            })
        },
        init() {

        }
    },
    created() {
        this.init();
        // console.log('this.$route',this.$route);
        // console.log('this.$router',this.$router);
    }
}
</script>

<style scoped>
*{
    /*border: 1px solid red;*/
}
.meeting-apply{

}
.apply-content{
    margin: 0 auto;
    width: 1240px;
    box-shadow: 0 0 2px 1px lightgrey;
    background: rgb(252,252,252);
    padding: 0 20px;
    box-sizing: border-box;
}
</style>
<style>
.el-time-spinner__item {
    width: 100%;
}
/*.el-transfer>.el-transfer-panel{*/
/*    width: 200px;*/
/*}*/
.el-transfer{
    height: 300px;
}
</style>
